#include "DrawCommand.h"
#include <GraphicsDrawingItem.h>

DrawCommand::DrawCommand(GraphicsDrawingItem* item, const QImage& oldImage, const QImage& newImage)
	:BaseCommand(true)
	, m_item(item)
	, m_oldImage(oldImage)
	, m_newImage(newImage)
{

}

void DrawCommand::undo()
{
	m_item->getItemData().setMaskImage(m_oldImage);
	m_item->update();
}

void DrawCommand::redo()
{
	if (m_isFirstPush) {
		m_isFirstPush = false;
		return;
	}
	m_item->getItemData().setMaskImage(m_newImage);
	m_item->update();
}
